package com.chen.qmzy.controller;

import com.chen.qmzy.entity.DwProductEntity;
import com.chen.qmzy.entity.ResultEntity;
import com.chen.qmzy.service.DwProService;
import com.chen.qmzy.tool.KoDoTool;
import jakarta.annotation.Resource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.io.File;
import java.util.UUID;


@CrossOrigin//跨域
@RestController//遵循RestFul
@RequestMapping("v2/DwPro/")
public class DwProController {
    @Resource
    private RedisTemplate<String ,String> redisTemplate;//Redis工具类
    @Resource
    DwProService dwProService;

    /**
     * 获取商品列表
     * @return json
     */
    @GetMapping("DwProList")
    private String getDwProList( @RequestParam("start") int start,
                                 @RequestParam("cnt") int cnt)
    {
        return dwProService.getDwProList(start,cnt);
    }
    /**
     * 根据id查询商品详情
     * @param id id
     * @return
     */
    @GetMapping("DwProductDetail")
    private String getDwProductDetail(@RequestParam(value = "id",defaultValue = "-1") int id){
        if (id==-1){
            return ResultEntity.fail(-10002);
        }
        DwProductEntity product = dwProService.getDwProductDetail(id);
        if( product!=null ){
            return ResultEntity.success(product);
        }else{
            return ResultEntity.fail(-10005);
        }
    }
}
